﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Business.aspx.cs" Inherits="Bulid_Business" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>代码生成器 - 后台代码生成</title>
    <link href="/Themes/Styles/style.css" rel="stylesheet" type="text/css" />
    <link href="/Themes/Scripts/Grid/pqgrid.min.css" rel="stylesheet" />

    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/Grid/jquery-ui.min.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/Grid/pqgrid.min.js" type="text/javascript" charset="GBK"></script>
    <script src="/Themes/Scripts/common.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/Jutil.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/Bussiness.js" type="text/javascript"></script>
    <script type="text/javascript">
        var table = GetQuery('table');//表名
        var db = GetQuery('db');
        var tableId = "";
        var remark = GetQuery('tableRemark');
        $(function () {
            ListGrid();
            $("#txt_TabelName").val(table);
            $("#txt_CreateDate").val(Jutil.dateFormat(new Date(), "yyyy-mm-dd"));
            $("input:radio[name='rt_CType']").click(function () {
                //alert(this.value);
                $("#sel_Templete").val(this.value);
                $("#sel_SubSpace").val(this.value)
                $("#lbl_Templete").html($("#sel_Templete").text);
                //$("#lbl_Templete").html(sel_SubSpace.options[sel_Templete.selectedIndex].text.replace(".vm", ""));
            });
        });
        //加载列表
        function ListGrid() {
            var GridParm = "";
            var url = "Business.aspx?action=List&type=null&table=" + table + "&db=" + db;
            var colM = [//colM：表头名称
                { title: "列名", width: 150, align: "center" },
                { title: "数据类型", width: 100, align: "center" },
                { title: "字段长度", width: 120, align: "center" },
                {
                    title: "是否主键", width: 100, align: "center", render: function (ui) {
                        var val = ui.rowData[3];
                        if (val == "√")
                            tableId = ui.rowData[0];//unescape(ui.rowData[3]);
                        return "<img src='/Themes/Images/" + (val == "√" ? "checkmark.gif" : "checknomark.gif") + "'/>";
                    }
                },
                {
                    title: "允许空", width: 60, align: "center", render: function (ui) {
                        return "<img src='/Themes/Images/" + (ui.rowData[4] == "" ? "checknomark.gif" : "checkmark.gif") + "'/>";
                    }
                },
                { title: "默认值", width: 50, align: "left" },
                { title: "描述", width: 250, align: "left" }
            ];
            //fields：要显示字段
            var fields = [
               "column", "datatype", "length", "key", "isnullable", "default", "remark"
            ];
            PQListNoPage("#gridList", url, colM, fields);
            $("#gridList").pqGrid({
                title: "<span style='color: #000000;'>" + table + "，" + decodeURI(remark) + "</span>",
                freezeCols: 5,//从第九列开始冻结 
                width: $(window).width() - 13,
                height: 250
            });
        }
        //刷新
        function windowload() {
            $("#gridList").pqGrid("refreshDataAndView");
        }
        //代码生成
        function CreateCode() {
            var table = $("#txt_TabelName").val();
            var templete = sel_Templete.options[sel_SubSpace.selectedIndex].text;//模板

            var para = "";
            para += "&db=" + escape(db);
            para += "&table=" + escape(table);
            para += "&templete=" + templete;
            para += "&tableId=" + tableId;
            para += "&type=" + $("#sel_SubSpace").val();

            var url = "/Bulid/Code_Browse.htm?action=Create" + para;

            CloseTab('Code_Browse');
            AddTabMenu('Code_Browse', url, '代码浏览', 'page_white_csharp.png', 'true');

            return false;
        }
    </script>
    <style>
        th {
            width: 80px;
            text-align: right;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div id="gridList"></div>
        <div class="div-body" id="basicInfo">
            <fieldset style="border: 1px solid #ccc;">
                <legend style="padding: 5px;">参数代码</legend>
                <table border="0" class="frm-find">
                    <tr>
                        <th>表 名 称：
                        </th>
                        <td>
                            <input id="txt_TabelName" runat="server" type="text" class="txt" style="width: 200px" disabled="disabled" />
                        </td>

                        <th>作  者：
                        </th>
                        <td>
                            <input id="txt_Author" runat="server" type="text" value="马山林" class="txt" style="width: 200px" disabled="disabled" />
                        </td>
                    </tr>
                    <tr>
                        <th>命名空间：
                        </th>
                        <td>
                            <select id="sel_SubSpace" class="select" runat="server" style="width: 207px;" disabled="disabled">
                                <option value="model">Model</option>
                                <option value="bll">BLL</option>
                                <option value="ibll">IBLL</option>
                                <%--<option value="Web">Web</option>--%>
                            </select>
                        </td>
                        <th>邮  箱：
                        </th>
                        <td>
                            <input id="txt_Email" runat="server" type="text" value="" class="txt" style="width: 200px" disabled="disabled" />
                        </td>
                    </tr>
                    <tr>
                        <th>公  司：
                        </th>
                        <td>
                            <input id="txt_Company" type="text" runat="server" class="txt" value="" style="width: 200px" disabled="disabled" />
                        </td>
                        <th>创建日期：
                        </th>
                        <td>
                            <input id="txt_CreateDate" type="text" class="txt" style="width: 200px" disabled="disabled" /></td>
                    </tr>
                </table>
            </fieldset>
            <fieldset style="border: 1px solid #ccc;">
                <legend style="padding: 5px;">生成代码类型</legend>
                <div class="lbl_fie">
                    <label>
                        <input name="rt_CType" value="model" type="radio" checked="checked" />实体类</label>
                    <label>
                        <input name="rt_CType" value="bll" type="radio" />业务逻辑类</label>
                    <label>
                        <input name="rt_CType" value="ibll" type="radio" />业务逻辑接口类</label>
                </div>
            </fieldset>
            <fieldset style="border: 1px solid #ccc;">
                <legend style="padding: 5px;">代码模板组件类型</legend>
                <div>
                    <label id="lbl_Templete">Model</label>
                    <select id="sel_Templete" class="select" runat="server" style="width: 207px;" disabled="disabled">
                        <option value="model">Model.vm</option>
                        <option value="bll">Bll.vm</option>
                        <option value="ibll">IBll.vm</option>
                    </select>
                </div>
            </fieldset>
        </div>
        <div class="aui_buttons">
            <span id="btnCreate" class="btn_span" onclick="CreateCode();">生成操作</span>
        </div>
    </form>
</body>
</html>
